# coding: UTF-8
import codeConfig as cfg;

def genFile(inFile, outFile):
    lines = open(inFile).readlines();  #打开文件，读入每一行
    fp = open(outFile, 'w');
    for s in lines:
        s = s.replace('??Project',cfg.sProject);
        s = s.replace('??Author',cfg.sAuthor);
        s = s.replace('??Year',cfg.today.strftime('%Y'));
        s = s.replace('??Month',cfg.today.strftime('%m'));
        s = s.replace('??Day',cfg.today.strftime('%d'));
        s = s.replace('??Module',cfg.sModule);
        s = s.replace('??Type',cfg.sType);
        s = s.replace('??TYPE',cfg.sType.upper());
        s = s.replace('??Space',cfg.sSpace);
        fp.write(s);
    fp.close();  # 关闭文件
    print("Generate File: "+ outFile);

outFile = cfg.sProjectPath+cfg.srcDir+'/'+cfg.sModule+'/'+cfg.sType+'.cpp';
genFile('template.cpp.in', outFile);

outFile = cfg.sProjectPath+cfg.includeDir+'/'+cfg.sModule+'/'+cfg.sType+'.h';
genFile('template.h.in', outFile);

